package com.ssyc.gsk_master.adapter;

import android.content.Context;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.ssyc.common.adapter.CommonAdapter;
import com.ssyc.common.adapter.ViewHolder;
import com.ssyc.common.utils.ScreenUtils;
import com.ssyc.gsk_master.R;
import com.ssyc.gsk_master.bean.HomeInfo;

import java.util.List;


/**
 * 首页的适配器
 * Created by Administrator on 2018/6/19 0019.
 */

public class HomeGvAdapter extends CommonAdapter<HomeInfo> {

    private Context context;
    private LinearLayout.LayoutParams lp;

    public HomeGvAdapter(Context context, List<HomeInfo> datas, int layoutId) {
        super(context, datas, layoutId);
        this.context = context;
        int lvWidth = ScreenUtils.getScreenWidth(context) * 80 / 374;
        int lvHeight = lvWidth * 56 / 80;
        lp = new LinearLayout.LayoutParams(lvWidth, lvHeight);
    }

    @Override
    public void convert(ViewHolder holder, HomeInfo homeInfo) {
        //设置图片
        ImageView iv = holder.getView(R.id.lv);
        iv.setLayoutParams(lp);
        iv.setImageResource(homeInfo.resId);
        //设置名称
        TextView tv = holder.getView(R.id.tv);
        tv.setText(homeInfo.name);
    }
}
